import { DescItem } from '/@/components/Description';
import { BasicColumn, FormSchema } from '/@/components/Table';
// 表格字段
export const columns: BasicColumn[] = [
  {
    title: '用户名',
    dataIndex: 'buildingName',
  },
  {
    title: '区域位置',
    dataIndex: 'area',
  },
  {
    title: '标题',
    dataIndex: 'address',
  },
  {
    title: '价格',
    dataIndex: 'minRentMoney',
  },
  {
    title: '发布时间',
    dataIndex: 'createTime',
  },
  {
    title: '起租时间',
    dataIndex: 'rentTime',
  },
  {
    title: '状态',
    dataIndex: 'status',
  },
  {
    title: '是否置顶',
    dataIndex: 'isTopping',
  },
  {
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
    width: 450,
    fixed: 'right',
  },
];
// 表单
export const searchFormSchema: FormSchema[] = [
  {
    field: 'buildingName',
    label: '用户名',
    component: 'Input',
    colProps: { span: 4 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'address',
    label: '标题',
    component: 'Input',
    colProps: { span: 4 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'area',
    label: '区域',
    colProps: { span: 4 },
    component: 'Select',
    componentProps: {
      placeholder: '请选择',
      options: [
        { label: '区域一', value: '区域一' },
        { label: '区域二', value: '区域二' },
      ],
    },
  },
  {
    field: 'status',
    label: '状态',
    component: 'Select',
    componentProps: {
      placeholder: '请选择',
      options: [
        { label: '已上线', value: '已上线' },
        { label: '已下线', value: '已下线' },
      ],
    },
    colProps: { span: 4 },
  },
  {
    field: 'isTopping',
    label: '是否置顶',
    component: 'Select',
    componentProps: {
      placeholder: '请选择',
      options: [
        { label: '是', value: '是' },
        { label: '否', value: '否' },
      ],
    },
    colProps: { span: 4 },
  },
];

// 表格数据
export const dataSource = [
  {
    id: 1,
    buildingName: 'SKY',
    area: '纽约/曼哈顿',
    address: '67 Mott St, New York, NY 10013',
    minRentMoney: '$2000/月',
    createTime: '2021-5-20 13:20:20',
    rentTime: '2021-5-20',
    status: '已上线',
    isTopping: '是',
    // redBook: 'ZAN@123.com',
    // instargran: 'ZAN@123.com',
    seoTitle: 'seo标题',
    seoDesc: 'seo描述',
    seoKeyWord: 'seo关键字',
    seoUrl: 'seo-URL',
    pic: 'pic-URL',
    remark: '简介',
  },
  {
    id: 2,
    buildingName: 'SKY',
    area: '纽约/曼哈顿',
    address: '67 Mott St, New York, NY 10013',
    minRentMoney: '$2000/月',
    createTime: '2021-5-20 13:20:20',
    rentTime: '2021-5-20',
    status: '已下线',
    isTopping: '是',
    seoTitle: 'seo标题',
    seoDesc: 'seo描述',
    seoKeyWord: 'seo关键字',
    seoUrl: 'seo-URL',
    pic: 'pic-URL',
    remark: '简介',
  },
];

export const getAccountList = () => {
  return dataSource;
};

export const buildingFormSchema: FormSchema[] = [
  {
    field: 'buildingName',
    label: '大楼名称',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'detailAddr',
    label: '详细地址',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'area',
    label: '区域位置',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'minRentMoney',
    label: '最低租金',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'school',
    label: '学校',
    component: 'Select',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请选择',
      options: [
        { label: '哈佛大学', value: '哈佛大学' },
        { label: '牛津大学', value: '牛津大学' },
      ],
    },
  },
  {
    field: 'supportingOfOwner',
    label: '业主配套特点(选填)',
    component: 'Select',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '可多选',
      mode: 'multiple',
      options: [
        { label: '哈佛大学', value: '哈佛大学' },
        { label: '牛津大学', value: '牛津大学' },
      ],
    },
  },
  {
    field: 'supportingOfHouse',
    label: '房屋配置特点(选填)',
    component: 'Select',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '可多选',
      mode: 'multiple',
      options: [
        { label: '哈佛大学', value: '哈佛大学' },
        { label: '牛津大学', value: '牛津大学' },
      ],
    },
  },
  {
    label: '添加封面图',
    field: 'coverUrl',
    component: 'Upload',
    slot: 'coverUrlSlot',
    rules: [
      {
        required: true,
        validator: async (_rule, value) => {
          if (!value) {
            /* eslint-disable-next-line */
            return Promise.reject('请添加首图');
          }
          return Promise.resolve();
        },
        trigger: 'change',
      },
    ],
  },
  {
    field: 'otherPic',
    label: '添加其他图片',
    component: 'Upload',
    componentProps: {
      api: '',
      accept: ['jpg', 'jepg', 'png', 'jpeg', 'JPG', 'PNG', 'JEPG', 'JPEG'],
      maxSize: 5,
    },
  },
  {
    label: '大楼简介',
    field: 'remark',
    component: 'InputTextArea',
    componentProps: {
      rows: 4,
      placeholder: '请输入',
    },
    dynamicRules: () => {
      return [
        {
          required: false,
          max: 200,
          message: '简介不能超过200字',
        },
      ];
    },
  },
  {
    label: '',
    field: '',
    component: 'Input',
    slot: 'buttonSlot',
  },
  {
    field: 'seoTitle',
    label: 'SEO标题',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'seoDesc',
    label: 'SEO描述',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'seoKeyWord',
    label: 'SEO关键字',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'seoUrl',
    label: 'SEO-URL',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'pic',
    label: '图片ALT',
    component: 'Input',
    colProps: { span: 12 },
    componentProps: {
      placeholder: '请输入',
    },
  },
];

export const SEOConfigFormSchema: FormSchema[] = [
  {
    field: 'seoTitle',
    label: 'SEO标题',
    component: 'Input',
    colProps: { span: 22 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'seoDesc',
    label: 'SEO描述',
    component: 'Input',
    colProps: { span: 22 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'seoKeyWord',
    label: 'SEO关键字',
    component: 'Input',
    colProps: { span: 22 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'seoUrl',
    label: 'SEO-URL',
    component: 'Input',
    colProps: { span: 22 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'pic',
    label: '图片ALT',
    component: 'Input',
    colProps: { span: 22 },
    componentProps: {
      placeholder: '请输入',
    },
  },
];

export const ViewData: any = {
  username: 'test',
  nickName: 'VB',
  age: 123,
  phone: '15695909xxx',
  email: '190848757@qq.com',
  addr: '厦门市思明区',
  sex: '男',
  certy: '3504256199xxxxxxxxx',
  tag: 'orange',
};

export const schema: DescItem[] = [
  {
    field: 'username',
    label: '用户名',
  },
  {
    field: 'nickName',
    label: '昵称',
    render: (curVal, data) => {
      return `${data.username}-${curVal}`;
    },
  },
  {
    field: 'phone',
    label: '联系电话',
  },
  {
    field: 'email',
    label: '邮箱',
  },
  {
    field: 'addr',
    label: '地址',
  },
];
